#ifndef MISSION_H_INCLUDED
#define MISSION_H_INCLUDED

#include <fstream>

#include "monster.h"
#include "player.h"

class Game;
class Monster;  //temporary, will include proper header files
class Player;

class Mission
{
public:
    Mission(Player* p, Game* g, const int& id);
    virtual ~Mission();

    void readText(const int& n, std::ifstream& infile);
    void setNexts(const int& i1, const int& i2);

    std::string getText() const { return text; }
    int getID() const { return ID; }
    virtual bool getPuzzle() const = 0;
    virtual int getExperience() const = 0;

    virtual void save(std::ostream& outfile) const;
    void completeMission();
    void failMission();
protected:
    Player* playerChar;
    Game* game;
    std::string text;
    int ID;
    int next1;
    int next2;
};

class Puzzle : public Mission
{
public:
    Puzzle(Player* p, Game* g, const int& id);
    void setData(const int& ans, const int& marg, const int& exp);
    void answerTry(const int& ans);
    int getExperience() const { return experience; }
    bool getPuzzle() const { return true; }

    void save(std::ostream& outfile) const;
private:
    int answer;
    int errorMargin;
    int experience;
};

class Combat : public Mission
{
public:
    Combat(Player* p, Game* g, const int& id);
    ~Combat();

    void setMonster(const std::string& name, const int& hp, const int& atk, const int& def, const int& spd, const int& exp);
    bool getPuzzle() const { return false; }
    void startCombat();
    void speedCheck();
    void nextTurn();
    int getExperience() const;

    void save(std::ostream& outfile) const;
private:
    Monster* enemy;
    bool autoc;
};

#endif // MISSION_H_INCLUDED
